package com.xy.prototype;

import com.xy.config.ProtoTypeConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/10 15:19
 * @description
 */
public class ProtoTypeTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ProtoTypeConfig.class);
        Object monster1 = applicationContext.getBean("monster");

        // 默认 @Scope("singleton") 通过@Scope("prototype")设置为原型模式
        Object monster2 = applicationContext.getBean("monster");
        System.out.println(monster1 == monster2);

    }
}
